<template>
    <view>
        <uni-list>
            <uni-list-item title="基本信息" link to="/pages/user/info-edit"></uni-list-item>
            <uni-list-item title="相册" link to="/pages/user/album-edit"></uni-list-item>
            <uni-list-item title="标签信息" link to="/pages/user/tag-edit"></uni-list-item>
        </uni-list>
        <uni-list v-show="false">
            <uni-list-item title="个人首页展示">
                <template slot="footer">
                    <switch :checked="showInList" @change="setShowInList"/>
                </template>
            </uni-list-item>
        </uni-list>
    </view>
</template>

<script>
    import {mapState} from 'vuex'
    import store from "../../vuex/store"

    export default {
        computed: mapState([
            'userInfo'
        ]),
        data() {
            return {
                showInList: false,
                isVerified: this.$store.state.isVerified
            }
        },
        onLoad() {
        },
        methods: {
            goDetail() {
                uni.navigateTo({
                    url: '/pages/detail/detail?userId=' + this.userInfo.id
                })
            },
            setShowInList(e) {
                store.commit('SET_SHOW_IN_LIST', this.showInList)
                if (!this.isVerified && e.detail.value) {
                    this.showInList = false
                    uni.showToast({
                        icon: 'none',
                        title: '请先完善资料哦'
                    })
                    console.log(this.showInList);
                    return
                }
                this.$http.put('/app/user-showInList?showInList=' + this.showInList)
                    .catch(res => {
                        uni.showToast({
                            icon: 'none',
                            title: res.data.errorMsg
                        })
                    })
            }
        }
    }
</script>

<style>

</style>
